package br.com.sovi.gwt.client.rpc;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.StatusCodeException;

public abstract class SecureAsyncCallback<T> implements AsyncCallback<T> {

	@Override
	public void onFailure(Throwable caught) {
		if (caught instanceof StatusCodeException) {
			StatusCodeException e = (StatusCodeException) caught;
			if (e.getStatusCode() == 401) {
				History.newItem("logoff");

				GWT.log("NAO AUTORIZADO", caught);
				return;
			}
		}
	}

}
